package com.cheer.vo;

import com.cheer.entity.Organization;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

@Data
@Accessors(chain = true)
public class OrganizationTreeVO {

    /**
     * 机构Id
     */
    private Long orgId;

    /**
     * 机构名称
     */
    private String orgName;

    /**
     * 机构类型 - 团委 = 1 行业系统 = 2
     */
    private Integer orgType;

    /**
     * 是否为分类
     */
    private Boolean category;

    /**
     * 下级机构
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private List<OrganizationTreeVO> children;

    public static OrganizationTreeVO build(Organization organization, List<OrganizationTreeVO> children) {
        OrganizationTreeVO organizationTreeVO = new OrganizationTreeVO();
        organizationTreeVO.setOrgId(organization.getId());
        organizationTreeVO.setOrgType(organization.getOrgType());
        organizationTreeVO.setOrgName(organization.getOrgName());
        organizationTreeVO.setCategory(organization.getCategory());
        organizationTreeVO.setChildren(children);
        return organizationTreeVO;
    }
}
